﻿using DevExpress.XtraEditors;
using DXApplicationTangche.UC.门店出入库.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.标签打印
{
    public partial class Form在制品盘点 : DevExpress.XtraEditors.XtraForm
    {
        private List<TagPrintDTO> tagPrintDTOs = new List<TagPrintDTO>();
        private TagPrintDTO tagPrint = new TagPrintDTO();
        public Form在制品盘点()
        {
            InitializeComponent();
        }
        private void textBox水洗_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (!String.IsNullOrWhiteSpace(this.textBox水洗.Text))
                {
                    try
                    {
                        //  入库
                        this.tagPrint = 出入库Service.garmentQCWaitStockIn(this.textBox水洗.Text.Trim());
                        try
                        {
                            if (!String.IsNullOrEmpty(this.tagPrint.styleSizeCd))
                            {
                                this.tagPrint.styleSizeCd = this.tagPrint.styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", "");
                            }
                        }
                        catch { }
                        //  gridcontrol显示
                        if (!String.IsNullOrEmpty(this.tagPrint.inventoryNo))
                        {
                            if (this.tagPrintDTOs.Count > 0)
                            {
                                if (!this.tagPrintDTOs.Exists(dto => dto.inventoryNo.Equals(this.tagPrint.inventoryNo)))
                                {
                                    this.tagPrintDTOs.Add(this.tagPrint);
                                }
                            }
                            else
                            {
                                this.tagPrintDTOs.Add(this.tagPrint);
                            }
                        }
                        this.gridControl待检仓一览.DataSource = this.tagPrintDTOs;
                        this.gridView待检仓一览.RefreshData();
                        this.gridView待检仓一览.BestFitColumns();
                        this.textBox水洗.Clear();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("请扫码");
                }
            }
        }
        private void Form入库_Load(object sender, EventArgs e)
        {
            this.ActiveControl = this.textBox水洗;
        }

        private void simpleButton导出excel_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出Excel";
            fileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                this.gridControl待检仓一览.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}